<template>
  <div>
    <van-field label="名称" v-model="form.name"/>
    <van-field label="性别" v-model="form.sex"/>
    <van-field label="工资" v-model="form.money"/>

    <select v-model="form.cid">所属部门:
      <option :value="i.id" v-for="i in dlist">{{ i.name }}</option>
    </select>
    <br>
    <br>
    <van-button @click="add">添加</van-button>
  </div>
</template>

<script>
export default {
  name: "staff",
  data() {
    return {
      dlist: [],
      form: {}
    }
  },

  methods: {
    getlist() {
      this.axios.get('demp').then(res => {
        this.dlist = res.data.list
      })
    },
    add() {
      this.axios.post('staff', this.form).then(res => {
        console.log(res)
      })
    }
  },

  mounted() {
    this.getlist()
  }
}
</script>

<style scoped>

</style>
